﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Imports Commander_Wars.Spieletools
Public Class LandschaftstexturRiff
    Inherits ObjektLandschaftsTextur
    Dim Riff As Objekt3D


    Public Sub New()
        ID = "RIFF"
        Landschaftsname = "Riff"
        Select Case My.Settings.CommanderWarsGameMoodus
            Case CommanderWarsGameModi.CommanderWars2, CommanderWarsGameModi.AdvanceWarsDC
                Deckung = 2
                Frame = False
            Case Else
                Frame = True
                Deckung = 1
        End Select
        Tarnung = True
        KP = -1
        Select Case My.Settings.TerrainStyle
            Case TerrainStyle.CommanderWars2, TerrainStyle.AdvanceWarsDC
                TexturenLaden(New String() {"Riff+N+O+S+W", "Riff1+N+O+S+W", "Riff2+N+O+S+W", "Riff3+N+O+S+W"})
            Case Else
                TexturenLaden(New String() {"Riff+N+O+S+W"})
        End Select

        Normal = -1
        ÜbergängeLaden("Küste")

        If My.Settings.draw3D Then
            Ini3D()
        Else
            Ausrichtungslandschaften = New String() {"SEE", "STRAND", "RIFF", "BRÜCKE", "ZUGBRÜCKE", "BAUBRÜCKE", "RAUESEE", "NEBEL"}
        End If
    End Sub
    Public Overrides Function BildID(ByVal X As Integer, ByVal Y As Integer, ByVal Spielfeld As ObjektSpielfeld) As Integer
        Dim Bild As Integer = MyBase.BildID(X, Y, Spielfeld)
        If Bild >= 0 Then
            Return Zufallszahl(0, Texturen.Length - 1)
        Else
            Return Bild
        End If
    End Function
    Public Overrides Function DrawSpecialStyle(ByVal BildID As Integer, ByVal Fog As Nebelarten, ByVal Alpha As Integer, ByVal X As Integer, ByVal Y As Integer) As Boolean
        Select Case My.Settings.TerrainStyle
            Case TerrainStyle.AdvanceWarsDC
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, 0)
            Case TerrainStyle.CommanderWars2
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, 0)
            Case Else
                Return False
        End Select
    End Function

    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)
        Malen3D(p_MatCube, "See", Landschaft) 'ganz normales Meer malen

        'und dann ein paar Riffe draufzeichnen.
        Riff.Malen(p_MatCube)
        'Grafikengine.Grafikkarte.SetTexture(0, TexturRiff)
        'Dim standardMatrix As Matrix = Grafikengine.Grafikkarte.Transform.World
        'Grafikengine.Grafikkarte.Transform.World = p_MatCube
        'Grafikengine.Grafikkarte.VertexFormat = CustomVertex.PositionTextured.Format

        ''Riff 1:
        'Dim cube(4) As CustomVertex.PositionTextured
        'cube(0) = New CustomVertex.PositionTextured(0.23, 0.0, 0.13, 1, 1)
        'cube(1) = New CustomVertex.PositionTextured(0.16, 0.0, 0.21, 0, 1)
        'cube(2) = New CustomVertex.PositionTextured(0.16, 0.1, 0.13, 0.5, 0)
        'cube(3) = New CustomVertex.PositionTextured(0.08, 0.0, 0.07, 1, 1)
        'cube(4) = New CustomVertex.PositionTextured(0.23, 0.0, 0.13, 0, 1)
        'Grafikengine.Grafikkarte.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, cube)

        ''Riff 2:
        'cube(0) = New CustomVertex.PositionTextured(0.83, 0.0, 0.67, 1, 1)
        'cube(1) = New CustomVertex.PositionTextured(0.85, 0.0, 0.79, 0, 1)
        'cube(2) = New CustomVertex.PositionTextured(0.8, 0.08, 0.72, 0.5, 0)
        'cube(3) = New CustomVertex.PositionTextured(0.72, 0.0, 0.73, 1, 1)
        'cube(4) = New CustomVertex.PositionTextured(0.83, 0.0, 0.67, 0, 1)
        'Grafikengine.Grafikkarte.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, cube)

        ''Riff 3:
        'cube(0) = New CustomVertex.PositionTextured(0.21, 0.0, 0.8, 1, 1)
        'cube(1) = New CustomVertex.PositionTextured(0.2, 0.0, 0.93, 0, 1)
        'cube(2) = New CustomVertex.PositionTextured(0.16, 0.03, 0.86, 0.5, 0)
        'cube(3) = New CustomVertex.PositionTextured(0.1, 0.0, 0.85, 1, 1)
        'cube(4) = New CustomVertex.PositionTextured(0.21, 0.0, 0.8, 0, 1)
        'Grafikengine.Grafikkarte.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, cube)


        ''Wieder den Ursprungsstatus wiederherstellen..
        'Grafikengine.Grafikkarte.Transform.World = standardMatrix
    End Sub

    Public Overrides Sub Ini3D()
        Riff = New Objekt3D
        Riff.MeshBildLaden(My.Settings.Resourcenpfad + "Landschaften\Meshes\Riff.x")
    End Sub

    Public Overrides Sub Tick()

    End Sub
End Class










Public Class LandschaftstexturRaue_See
    Inherits ObjektLandschaftsTextur



    Public Sub New()
        ID = "RAUESEE"
        Landschaftsname = "Raue See"
        Deckung = 2
        Tarnung = False
        KP = -1
        Frame = True
        TexturenLaden(New String() {"Raue See+N+O+S+W"})
        Normal = -1
        Ausrichtungslandschaften = New String() {"SEE", "STRAND", "RIFF", "BRÜCKE", "ZUGBRÜCKE", "BAUBRÜCKE", "RAUESEE", "NEBEL"}
        ÜbergängeLaden("Küste")
    End Sub

    Public Overrides Function DrawSpecialStyle(ByVal BildID As Integer, ByVal Fog As Nebelarten, ByVal Alpha As Integer, ByVal X As Integer, ByVal Y As Integer) As Boolean
        Dim Frame As Integer = ObjektLandschaft.Frame
        If ObjektLandschaft.HochZählen < 0 Then
            Frame = ObjektLandschaft.MaxFrames - Frame
        End If
        Select Case My.Settings.TerrainStyle
            Case TerrainStyle.AdvanceWarsDC
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, Frame)
            Case TerrainStyle.CommanderWars2
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, Frame)
            Case Else
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, Frame)
        End Select
    End Function

    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)
        Malen3D(p_MatCube, "See")
    End Sub

    Public Overrides Sub Ini3D()

    End Sub

    Public Overrides Sub Tick()

    End Sub
End Class














Public Class LandschaftstexturNebel
    Inherits ObjektLandschaftsTextur



    Public Sub New()
        ID = "NEBEL"
        Landschaftsname = "NEBEL"
        Select Case My.Settings.CommanderWarsGameMoodus
            Case CommanderWarsGameModi.CommanderWars2, CommanderWarsGameModi.AdvanceWarsDC
                Deckung = 1
            Case Else
                Deckung = 0
        End Select
        Groß = True
        Frame = False
        Tarnung = True
        KP = -1
        TexturenLaden(New String() {"Nebel+N+O+S+W"})
        Normal = -1
        Ausrichtungslandschaften = New String() {"SEE", "STRAND", "RIFF", "BRÜCKE", "ZUGBRÜCKE", "BAUBRÜCKE", "RAUESEE", "NEBEL"}
        ÜbergängeLaden("Küste")
    End Sub

    Public Overrides Function DrawSpecialStyle(ByVal BildID As Integer, ByVal Fog As Nebelarten, ByVal Alpha As Integer, ByVal X As Integer, ByVal Y As Integer) As Boolean
        Select Case My.Settings.TerrainStyle
            Case TerrainStyle.AdvanceWarsDC
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, 0)
            Case TerrainStyle.CommanderWars2
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, 0)
            Case Else
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, 0)
        End Select
    End Function

    Public Overrides Function BildID(ByVal X As Integer, ByVal Y As Integer, ByVal Spielfeld As ObjektSpielfeld) As Integer
        Dim Bild As Integer = MyBase.BildID(X, Y, Spielfeld)
        If Bild >= 0 Then
            Return Zufallszahl(0, Texturen.Length - 1)
        Else
            Return Bild
        End If
    End Function

    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)

    End Sub

    Public Overrides Sub Ini3D()

    End Sub

    Public Overrides Sub Tick()

    End Sub
End Class